import Response from '../../utils/response.js';
import { shjApi } from '../../utils/request.js';

// 获取用户token
export const checkUser = async (ctx) => {
  try {
    const response = await shjApi.post('/shuihuanjing/auth/getmenuuser', {}, {
      headers: {
        token: ctx.headers.token,
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    });
    
    if (response.data) {
        const { code, data } = response.data;

        if (code === '0000') {
            ctx.body = Response.success(data);
        }
    } else {
      console.error('获取数据失败:');
      ctx.body = Response.error('获取数据失败');
    }
  } catch (err) {
    console.error('请求失败:', err);
    ctx.body = Response.error('获取数据失败')
  }
};
